<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.stylethem {
	color: #000 !important;
	font-weight: bold !important;
	font-size: 24px !important;
}
.stylethem1 {font-weight: bold !important;}
-->
</style>
<script language="JavaScript" type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script language="JavaScript" type="text/javascript" src="ckeditor/sample.js"></script>
</head>
<body>
<?php
	function dequy_option__mnn($id,$nhandang)
		{
			$nhandang="&nbsp;&nbsp;&nbsp;".$nhandang;
			$a=mysql_query("select * from danhmucsp where parent = $id order by madanhmuc");
			while($b=mysql_fetch_array($a))
			{
				echo"<option value=\"$b[madanhmuc]\">$nhandang $b[tendanhmuc]</option>";
				dequy_option__mnn($b['madanhmuc'],$nhandang);
			}
		}
?>
	<form action="?thamso=themdanhmuc" method="post" enctype="multipart/form-data" name="form1">
    	<table width="400" border="0" align="center" cellpadding="3" cellspacing="3">
            <tr align="center" bgcolor="#333333">
              <td colspan="2"><span class="stylethem">Danh mục sản phẩm</span></td>
            </tr>
            
            
            <tr bgcolor="#F2F2F2">
                <td width="20%">
                    <strong>Tên Danh Mục: </strong>
                </td>
                <td width="80%">
                    <input type='text' name='tendanhmuc' size='50'/>
                </td>
            </tr>
            
            <tr align="center" bgcolor="#CFCFCF">
                <td width='20%'>&nbsp;</td>
                <td width='80%'><input type="submit" class="nut_chapnhan" value="Chấp nhận" name="them"></td>
            </tr>
        </table>
    </form>
</body>
</html>
<?php
function ktfile($tenfile)
	{
		$pattern='#.+\.(gif|jpg|png)$#i';
		if(preg_match($pattern,$tenfile)==1)
		{
    		return 1;
		}
		else
		{
    		return 0;
		}
	}
	if(isset($_POST["them"]))
	{
		
		
		$tendanhmuc = $_POST['tendanhmuc'];
		
		if ($tendanhmuc!="")
		{
			$sql = "INSERT INTO `danhmucsp` (`madanhmuc`, `tendanhmuc`)
					VALUES ('' , '$tendanhmuc')";
			$result = mysql_query($sql);
			if($result)
			{
				/*echo "<script>alert('ThÃªm thÃ nh cÃ´ng');</script>";*/
				/*echo "<script>window.location=('?thamso=dsdanhmuc');</script>";*/
			}
		}
		else
			echo "<script>alert('KhÃ´ng Ä‘Æ°á»£c bá»� trá»‘ng tÃªn danh má»¥c');</script>";
			
		
		
	}
?>